/**
 * 
 */
package com.chinasofti.project.service.user.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chinasofti.project.common.SimpleDigestUtil;
import com.chinasofti.project.dal.mapper.BzUserMapper;
import com.chinasofti.project.dal.model.BzUser;
import com.chinasofti.project.service.user.ForgetThePasswordService;

/**
 * @author liuji
 *
 */
@Service("forgetThePasswordService")
public class ForgetThePasswordServiceImpl implements ForgetThePasswordService {
	@Autowired
	public BzUserMapper bzUserMapper;
	/* (non-Javadoc)
	 * @see com.chinasofti.project.service.user.ForgetThePasswordService#forgetThePassword1()
	 */
	@Override
	public boolean forgetThePassword1(String userPassword, int userId) {
		BzUser bzUser = bzUserMapper.selectByPrimaryKey(userId);
		System.out.println("userPassword" + userPassword);
		System.out.println("bzUser.getUserPassword()" + bzUser.getUserPassword());
		SimpleDigestUtil.encryptSHA(bzUser.getUserPassword());
		if (userPassword.equals(bzUser.getUserPassword())) {
			return true;
		}
		return false;
	}

	@Override
	public boolean forgetThePassword2(String newUserPassword, int userId) {
		BzUser bzUser = bzUserMapper.selectByPrimaryKey(userId);
		if (bzUser.equals(newUserPassword)) {
			return true;
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.chinasofti.project.service.user.ForgetThePasswordService#
	 * modifiUserPassword(com.chinasofti.project.dal.model.BzUser)
	 */
	@Override
	public void modifiUserPassword(BzUser bzUser) {
		bzUserMapper.updateByPrimaryKeySelective(bzUser);
	}

}
